<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
div {
    width:200px; height:100px; border:solid 1px red; padding:50px;
}
#wrap {
    position:relative;
    border-width:20px; 
}
</style>
</head>
<body>

<div id="wrap">
    <div id="sub">
        <div id="box"></div>
    </div>
</div>

<script>

var box = document.getElementById("box");
alert(box.offsetLeft);
alert(box.offsetParent.id);

</script>


</body>
</html> 
